/usr/local:
  archive.extracted:
    - source: salt://modules/prometheus/files/node_exporter-1.3.0.linux-amd64.tar.gz
    - if_issing: /usr/local/node_exporter-1.3.0.linux-amd64

{{ pillar['node_exporter_dir'] }}:
  file.symlink:
    - target: /usr/local/node_exporter-1.3.0.linux-amd64
    - unless: test -d {{ pillar['node_exporter_dir'] }}

/usr/lib/systemd/system/node_exporter.service:
  file.managed:
    - source: salt://modules/prometheus/files/node_exporter.service.j2
    - template: jinja
  cmd.run:
    - name: systemctl daemon-reload

node_exporter.service:
  service.running:
    - enable: true
    - watch:
      - cmd: /usr/lib/systemd/system/node_exporter.service
